package com.zsgeek.wisdchain.qutu.base.event;

import com.alibaba.fastjson.JSON;

/**
 * EventBus数据传递的基类
 *
 * @date 2018/10/17
 */
public class BaseEvent<T> {
    private int event;  //事件id
    private int intValue, mappingId, tokenId;   //整形参数
    private String stringValue, tradeTokenName; //字符串参数
    private boolean booleanValue;
    private Object data;    //Object参数

    public BaseEvent(int event) {
        this.event = event;
    }

    public BaseEvent(int event, Object data) {
        this.event = event;
        this.data = data;
    }

    public BaseEvent(int event, String str) {
        this.event = event;
        this.stringValue = str;
    }

    public BaseEvent(int event, boolean booleanValue) {
        this.event = event;
        this.booleanValue = booleanValue;
    }

    public BaseEvent(int event, int intValue, String stringValue) {
        this.event = event;
        this.intValue = intValue;
        this.stringValue = stringValue;
    }

    public BaseEvent(int event, int intValue, int mappingId, String tradeTokenName, int tokenId) {
        this.event = event;
        this.intValue = intValue;
        this.mappingId = mappingId;
        this.tradeTokenName = tradeTokenName;
        this.tokenId = tokenId;
    }

    public BaseEvent(int event, boolean booleanValue, int intValue, String stringValue) {
        this.event = event;
        this.booleanValue = booleanValue;
        this.intValue = intValue;
        this.stringValue = stringValue;
    }

    public int getEvent() {
        return event;
    }

    public int getIntValue() {
        return intValue;
    }

    public int getMappingId() {
        return mappingId;
    }

    public int getTokenId() {
        return tokenId;
    }

    public void setIntValue(int intValue) {
        this.intValue = intValue;
    }

    public String getTradeTokenName() {
        return tradeTokenName;
    }

    public String getStringValue() {
        return stringValue;
    }

    public void setStringValue(String stringValue) {
        this.stringValue = stringValue;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public boolean isBooleanValue() {
        return booleanValue;
    }

    public void setBooleanValue(boolean booleanValue) {
        this.booleanValue = booleanValue;
    }

    public <T> T parseStringValueObject(Class<T> clazz) {
        try {
            return JSON.parseObject(stringValue, clazz);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
